/**
 * 
 */
package GUI.main;

import java.awt.Font;
import java.io.IOException;
import java.net.UnknownHostException;

import javax.swing.JOptionPane;

import GUI.main.dialogs.LoginDialog;
import GUI.network.OfficeConnection;

/**
 * @author Chris Bayruns
 * 
 */
public class MainClient {

	/**
	 * @author Chris Bayruns
	 * @param args
	 */
	public final static String FRAME_TITLE = new String("The Office 2.0");
	public static final Font LOGO_FONT = new Font(Font.SANS_SERIF, Font.BOLD,
			20);
	public static final String LOGO_STRING = new String("the office 2.0");
	private static OfficeConnection officeConnection;
	private static MainFrame mf;
	private static LoginDialog ld;
	public static boolean loggedIn = false;
	public static void main(String[] args) {
		getLogin().setVisible(true);
		getLogin().setModal(true);
		try {
			while(!loggedIn){System.out.print("");};
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("Logged In!");
		getMainFrame().pack();
		getMainFrame().setVisible(true);

	}

	public static MainFrame getMainFrame() {
		if (mf == null) {
			mf = new MainFrame();
		}
		return mf;
	}

	public static LoginDialog getLogin() {
		if (ld == null) {
			ld = new LoginDialog();
		}
		return ld;
	}

	public static OfficeConnection getConnection() {
		if (officeConnection == null) {

			try {
				officeConnection = new OfficeConnection("127.0.0.1", 12345);
			} catch (UnknownHostException e) {
				// TODO Auto-generated catch block
				JOptionPane.showMessageDialog(mf, "Server is not running.");
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return officeConnection;
	}

}
